package com.cdcas;

import java.util.Arrays;
import java.util.Comparator;

public class ArrayPerson {
    public static void main(String[] args) {
        Person[] people = {new Person("Alice", 25), new Person("Bob", 30)};
        Arrays.sort(people, Comparator.comparing(Person::getName)); //
        for (Person p :people) {
            System.out.println("name="+p.getName() +" age=" +p.getAge());
        }

        int index = Arrays.binarySearch(people, new Person("Bob", 0),
                Comparator.comparing(Person::getName));
        System.out.println(index);

    }
}
